﻿@model ConfigurationModel

@{
    Layout = "_ConfigurePlugin";
}

@await Component.InvokeAsync(typeof(StoreScopeConfigurationViewComponent))

<form asp-controller="CyberSource" asp-action="Configure" method="post">
    <div class="cards-group">
        <div class="card card-default">
            <div class="card-body">
                <p>
                    To enable this payment method, you'll need to:<br />
                    <br />
                    1. <a href="https://ebc2.cybersource.com/ebc2/registration/external" target="_blank">Sign-up for CyberSource account</a><br />
                    2. Go to <b>Payment Configuration</b> → <b>Key Management</b>. Generate key with type <b>REST - Shared Secret</b><br />
                    3. Fill in your account details below<br />
                </p>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="UseSandbox_OverrideForStore" asp-input="UseSandbox" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="UseSandbox" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="UseSandbox" />
                        <span asp-validation-for="UseSandbox"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="MerchantId_OverrideForStore" asp-input="MerchantId" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="MerchantId" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="MerchantId" asp-required="true" />
                        <span asp-validation-for="MerchantId"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="KeyId_OverrideForStore" asp-input="KeyId" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="KeyId" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="KeyId" asp-required="true" />
                        <span asp-validation-for="KeyId"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="SecretKey_OverrideForStore" asp-input="SecretKey" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="SecretKey" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="SecretKey" asp-required="true" html-attributes="@(new { value = Model.SecretKey })" />
                        <span asp-validation-for="SecretKey"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="TokenizationEnabled_OverrideForStore" asp-input="TokenizationEnabled" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="TokenizationEnabled" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="TokenizationEnabled" />
                        <span asp-validation-for="TokenizationEnabled"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="PaymentConnectionMethodId_OverrideForStore" asp-input="PaymentConnectionMethodId" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="PaymentConnectionMethodId" />
                    </div>
                    <div class="col-md-9">
                        <nop-select asp-for="PaymentConnectionMethodId" asp-items="@await (((ConnectionMethodType)Model.PaymentConnectionMethodId).ToSelectListAsync())" />
                        <span asp-validation-for="PaymentConnectionMethodId"></span>
                    </div>
                </div>
                <div class="form-group row" id="payer-authentication">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="PayerAuthenticationEnabled_OverrideForStore" asp-input="PayerAuthenticationEnabled" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="PayerAuthenticationEnabled" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="PayerAuthenticationEnabled" />
                        <span asp-validation-for="PayerAuthenticationEnabled"></span>
                    </div>
                </div>
                <nop-nested-setting asp-for="PayerAuthenticationEnabled">
                    <div class="form-group row" id="payer-authentication-force">
                        <div class="col-md-3">
                            <nop-override-store-checkbox asp-for="PayerAuthenticationRequired_OverrideForStore" asp-input="PayerAuthenticationRequired" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                            <nop-label asp-for="PayerAuthenticationRequired" />
                        </div>
                        <div class="col-md-9">
                            <nop-editor asp-for="PayerAuthenticationRequired" />
                            <span asp-validation-for="PayerAuthenticationRequired"></span>
                        </div>
                    </div>
                </nop-nested-setting>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="TransactionTypeId_OverrideForStore" asp-input="TransactionTypeId" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="TransactionTypeId" />
                    </div>
                    <div class="col-md-9">
                        <nop-select asp-for="TransactionTypeId" asp-items="@await (((TransactionType)Model.TransactionTypeId).ToSelectListAsync())" />
                        <span asp-validation-for="TransactionTypeId"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="CvvRequired_OverrideForStore" asp-input="CvvRequired" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="CvvRequired" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="CvvRequired" />
                        <span asp-validation-for="CvvRequired"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="AvsActionTypeId_OverrideForStore" asp-input="AvsActionTypeId" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="AvsActionTypeId" />
                    </div>
                    <div class="col-md-9">
                        <nop-select asp-for="AvsActionTypeId" asp-items="@await (((AvsActionType)Model.AvsActionTypeId).ToSelectListAsync())" />
                        <span asp-validation-for="AvsActionTypeId"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="CvnActionTypeId_OverrideForStore" asp-input="CvnActionTypeId" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="CvnActionTypeId" />
                    </div>
                    <div class="col-md-9">
                        <nop-select asp-for="CvnActionTypeId" asp-items="@await (((CvnActionType)Model.CvnActionTypeId).ToSelectListAsync())" />
                        <span asp-validation-for="CvnActionTypeId"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-override-store-checkbox asp-for="DecisionManagerEnabled_OverrideForStore" asp-input="DecisionManagerEnabled" asp-store-scope="@Model.ActiveStoreScopeConfiguration" />
                        <nop-label asp-for="DecisionManagerEnabled" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="DecisionManagerEnabled" />
                        <span asp-validation-for="DecisionManagerEnabled"></span>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3">
                        <nop-label asp-for="ConversionDetailReportingEnabled" />
                    </div>
                    <div class="col-md-9">
                        <nop-editor asp-for="ConversionDetailReportingEnabled" />
                        <span asp-validation-for="ConversionDetailReportingEnabled"></span>
                    </div>
                </div>
                <nop-nested-setting asp-for="ConversionDetailReportingEnabled">
                    <div class="form-group row">
                        <div class="col-md-3">
                            <nop-label asp-for="ConversionDetailReportingFrequency" />
                        </div>
                        <div class="col-md-9">
                            <nop-editor asp-for="ConversionDetailReportingFrequency" />
                            <span asp-validation-for="ConversionDetailReportingFrequency"></span>
                        </div>
                    </div>
                </nop-nested-setting>
                <div class="form-group row">
                    <div class="col-md-9 offset-md-3">
                        <button type="submit" name="save" class="btn btn-primary">@T("Admin.Common.Save")</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>

<script asp-location="Footer">
    $(document).ready(function() {
        $('#@Html.IdFor(model => model.PaymentConnectionMethodId)').change(toggleConnectionMethod);
        toggleConnectionMethod();
    });

    function toggleConnectionMethod() {
        var flexMicroform = '@((int)ConnectionMethodType.FlexMicroForm)';
        var selectedMethodId = $('#@Html.IdFor(model => model.PaymentConnectionMethodId)').val();
        if (selectedMethodId && selectedMethodId == flexMicroform) {
            $('#payer-authentication').showElement();
            $('#payer-authentication-force').showElement();
        } else {
            $('#payer-authentication').hideElement();
            $('#payer-authentication-force').hideElement();
        }
    }
</script>